package org.poem;

import org.poem.client.TimeClientHandler;
import org.poem.time.MultiplexerTimeServer;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class MainApp {

  private static ExecutorService singleThreadPool =
      new ThreadPoolExecutor(
          1,
          1,
          0L,
          TimeUnit.MILLISECONDS,
          new LinkedBlockingQueue<Runnable>(1024),
          new ThreadPoolExecutor.AbortPolicy());

  /**
   * 方法
   *
   * @throws IOException
   */
  public static void main(String... args) throws IOException {
    int port = 8088;
    singleThreadPool.execute(() -> new MultiplexerTimeServer(port));
    singleThreadPool.execute(() -> new TimeClientHandler("127.0.0.1", 8080));
      singleThreadPool.isShutdown();
    singleThreadPool.shutdown();
  }
}
